<?php declare(strict_types=1);


namespace app\model;

class UserGroup extends Base {

    protected $name = 'user_group';

    // 设置字段信息
    protected $schema = [
        'user_id'     => 'int',
        'group_id'   =>'string',
        'expire_at' => 'datetime',
        'create_at' => 'datetime',
        'update_at' => 'datetime',
    ];

    // User Groups
    public function groups(){
        return $this->hasMany('AuthGroup','group_id',"group_id");
    }

    // Get User Groups Of Enabled
    public function getUserGroupsByUserID(int $userID) : array {
        $result = $this->where('user_id','=',$userID)->column('group_id');
        return $result;
    }
}

 
